package com.zqcy.workbench.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.zqcy.workbench.R;
import com.zqcy.workbench.bean.TabConfiguration;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * 已添加应用item适配器
 */
public class AddTabAdapter extends BaseQuickAdapter<TabConfiguration, BaseViewHolder> {
    private Context context;

    public AddTabAdapter(Context context, List<TabConfiguration> data) {
        super(R.layout.item_tab_configuration, data);
        this.context = context;
    }

    @Override
    protected void convert(@NotNull BaseViewHolder helper, TabConfiguration item) {
        RelativeLayout layout = helper.getView(R.id.tab_configuration_layout);
        if (item.getTabId() == 99) {
            layout.setBackgroundResource(R.drawable.shape_dotted);
        } else {
            helper.setText(R.id.tab_configuration_text, context.getResources().getString(item.getTabName()));
            helper.getView(R.id.tab_configuration_img).setBackgroundResource(item.getTabIcon());
            layout.setBackground(null);
            layout.setBackgroundColor(context.getResources().getColor(R.color.f7f8f9));
        }
    }
}
